
<?php
header("Content-type:application/json; charset=UTF-8"); 
include "../connect.php";


//show data head
$sql_new =mysql_query("(SELECT na.c_id,na.c_section,n.c_id,n.c_category,n.c_public,n.c_title,n.c_post_on
from smm_news_category na left join smm_news n on na.c_id = n.c_category 
where  na.c_section='woman' and n.c_public='1' order by n.c_post_on DESC limit 0,3)
UNION
(SELECT ca.c_id,ca.c_section,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category
where  ca.c_section='woman' and a.c_public ='1' order by a.c_post_on DESC limit 0,3)
");

$json_data[numnew]=mysql_num_rows($sql_new);
while($rs=mysql_fetch_array($sql_new)){
	$json_data[d_new][]=array("c_title"=>$rs['c_title']);
}

//show data news
$sql_head =mysql_query("SELECT na.c_id,na.c_name,na.c_section,n.c_id,n.c_category,n.c_public,n.c_title,n.c_post_on,n.c_intro,n.c_image,n.c_home
from smm_news_category na left join smm_news n on na.c_id = n.c_category 
where  na.c_section='woman' and n.c_public='1' and n.c_home='1' order by n.c_post_on DESC limit 0,1");
$json_data[numhead]=mysql_num_rows($sql_head);
while($rs=mysql_fetch_array($sql_head)){
	$json_data[d_head][]=array(
		"c_title"=>"<a href='/detail_news.php?c_id=".$rs['c_id']."' target='_blank' title='".$rs['c_title']."'>".$rs['c_title']."</a>",
		"c_intro"=>$rs['c_intro'],
        "c_title1"=>"<a href='/detail_news.php?c_id=".$rs['c_id']."' target='_blank' title='".$rs['c_title']."'>".iconv_substr($rs['c_title'],0,27,"utf-8")."</a>",
	    "c_img"=>"<a href='/detail_news.php?c_id=".$rs['c_id']."' target='_blank' rel='".$rs['c_title']."'><img src='".str_replace("small","medium",$rs['c_image'])."' width='170' height='98' title='".$rs['c_title']."' border='0' ></a>",
	    "c_image"=>"<a href='/detail_news.php?c_id=".$rs['c_id']."' target='_blank'><img src=".str_replace("small","big",$rs['c_image'])."  width=465 height=300 title='".$rs['c_title']."' border=0></a>",
	);	

}
//show data article
$sql_article =mysql_query("SELECT ca.c_id,ca.c_name,ca.c_section,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on,a.c_intro,a.c_image,a.c_home
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category 
where  ca.c_section='woman' and ca.c_id !='46' and a.c_public='1'and a.c_home='1' order by a.c_post_on DESC limit 0,3");
$json_data[numarticle]=mysql_num_rows($sql_article);
while($rs=mysql_fetch_array($sql_article)){
	$json_data[d_article][]=array(
		"c_title"=>"<a href='/detail_article.php?c_id=".$rs['c_id']."' target='_blank' title='".$rs['c_title']."'>".$rs['c_title']."</a>",
		"c_intro"=>$rs['c_intro'],
        "c_title1"=>"<a href='/detail_article.php?c_id=".$rs['c_id']."' target='_blank' title='".$rs['c_title']."'>".iconv_substr($rs['c_title'],0,27,"utf-8")."</a>",
	    "c_img"=>"<a href='/detail_article.php?c_id=".$rs['c_id']."' target='_blank' rel='".$rs['c_title']."'><img src='".str_replace("small","medium",$rs['c_image'])."' width='170' height='98' title='".$rs['c_title']."' border='0' ></a>",
	    "c_image"=>"<a href='/detail_article.php?c_id=".$rs['c_id']."' target='_blank'><img src=".str_replace("small","big",$rs['c_image'])."  width=465 height=300 title='".$rs['c_title']."' border=0></a>",
	);	

}

//show data woman&fashion
$sql_f =mysql_query("SELECT ca.c_id,ca.c_section,ca.c_parent,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on,a.c_intro,a.c_image
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category
where a.c_category='7' or ca.c_parent='7'  and a.c_public ='1' order by a.c_post_on DESC limit 0,10");

$json_data[numfashion]=mysql_num_rows($sql_f);

while($rows=mysql_fetch_array($sql_f)){
   $fashion[c_id]=$rows[c_id];
   $fashion[c_image]=$rows[c_image];
   $fashion[c_title]=$rows[c_title];
   $fashion[c_intro]=$rows[c_intro];
   $json_data[d_f][]   = $fashion;

}

//show data healty&beauty
$sql_h =mysql_query("SELECT ca.c_id,ca.c_section,ca.c_parent,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on,a.c_intro,a.c_image
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category
where  a.c_category='9' or ca.c_parent='9' and a.c_public ='1' order by a.c_post_on DESC limit 0,3");

$json_data[numhealty]=mysql_num_rows($sql_h);
while($rs=mysql_fetch_array($sql_h )){
   $healty[c_id]=$rs[c_id];
   $healty[c_image]=$rs[c_image];
   $healty[c_title]=$rs[c_title];
   $json_data[d_h][]   = $healty;

}

//show data lifestyle
$sql_l =mysql_query("SELECT ca.c_id,ca.c_section,ca.c_parent,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on,a.c_intro,a.c_image
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category
where a.c_category='10' or ca.c_parent='10' and a.c_public ='1' order by a.c_post_on DESC limit 0,5");

$json_data[numlife]=mysql_num_rows($sql_l);
while($rows=mysql_fetch_array($sql_l)){
   $life[c_id]=$rows[c_id];
   $life[c_category]=$rows[c_category];
   $life[c_image]=$rows[c_image];
   $life[c_title]=$rows[c_title];
   $life[c_intro]=iconv_substr($rows[c_intro],0,60,"utf-8");
   $json_data[d_l][]   = $life;

}

//show data workingwoman
$sql_w =mysql_query("SELECT ca.c_id,ca.c_section,ca.c_parent,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on,a.c_intro,a.c_image
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category
where  a.c_category='11' or ca.c_parent='11' and a.c_public ='1' order by a.c_post_on DESC limit 0,5");

$json_data[numwork]=mysql_num_rows($sql_w);
while($rows=mysql_fetch_array($sql_w)){
   $work[c_id]=$rows[c_id];
   $work[c_image]=$rows[c_image];
   $work[c_title]=$rows[c_title];
   $work[c_intro]=iconv_substr($rows[c_intro],0,60,"utf-8");
   $json_data[d_w][]   = $work;

}

//show data mother_baby
$sql_b =mysql_query("SELECT ca.c_id,ca.c_section,ca.c_parent,a.c_id,a.c_category,a.c_public,a.c_title,a.c_post_on,a.c_intro,a.c_image
from smm_article_category ca left join smm_article a on ca.c_id = a.c_category
where  a.c_category IN ('23','24','25','26') or ca.c_parent IN ('23','24','25','26') and a.c_public ='1' order by a.c_post_on DESC limit 0,7");

$json_data[numbaby]=mysql_num_rows($sql_b);
while($rows=mysql_fetch_array($sql_b)){
   $mother[c_id]=$rows[c_id];
   $mother[c_image]= $rows[c_image];
   $mother[c_title]=$rows[c_title];
   $mother[c_intro]=iconv_substr($rows[c_intro],0,60,"utf-8");
   $json_data[d_b][]  = $mother;

}

//show data magazine
$sql_m =mysql_query("SELECT c_id,c_category,c_public,c_title,c_post_on,c_image
from smm_news where c_category in (56,57,58,59,60,61) and c_public ='1' order by c_post_on DESC");

$json_data[magazine]=mysql_num_rows($sql_m);
while($rows=mysql_fetch_array($sql_m)){
   $magazine[c_id]=$rows[c_id];
   $magazine[c_image]="<img src=".str_replace("small","medium",$rows['c_image'])." width=110 height=140 border='0'>";
   $magazine[c_title]=$rows[c_title];
   $json_data[d_m][]   = $magazine;

}
//show data Sweety Girls
$sql_s =mysql_query("SELECT c_id,c_category,c_public,c_title,c_post_on,c_image
from smm_article where c_category ='46' and c_public ='1' order by c_post_on DESC limit 0,4");

$json_data[sweety]=mysql_num_rows($sql_s);
while($rows=mysql_fetch_array($sql_s)){
   $sweety[c_id]=$rows[c_id];
   $sweety[c_image]="<img src=".$rows['c_image']." width=66 height=90 border='0'>";
   $sweety[c_title]=$rows[c_title];
   $json_data[d_s][]   = $sweety;

}
echo json_encode($json_data);
?>